package com.sokal.easycare.modules.trial.entity;

import org.hibernate.validator.constraints.Length;

import com.sokal.easycare.common.persistence.DataEntity;
import com.sokal.easycare.common.utils.StringUtils;

/**
 * 试算记录Entity
 * @author lihaipei
 * @version 2017-05-25
 */
public class TrialRecord extends DataEntity<TrialRecord> {
	
	private static final long serialVersionUID = 1L;
	private String productType;		// 产品类型
	private Double area;		// 面积
	private Double price;		// 价格
	private Double sum;		// 总和
	
	public TrialRecord() {
		super();
	}

	public TrialRecord(String id){
		super(id);
	}

	public TrialRecord(String productType, String area, String price){
		super();
		this.productType = productType;
		if (StringUtils.isNotBlank(area)) {
			this.area = Double.parseDouble(area);
		}
		if (StringUtils.isNotBlank(price)) {
			this.price = Double.parseDouble(price);
		}
		if (StringUtils.isNotBlank(price) && StringUtils.isNotBlank(area)) {
			this.sum = Double.parseDouble(area)*Double.parseDouble(price);
		}
	}

	@Length(min=0, max=255, message="产品类型长度必须介于 0 和 255 之间")
	public String getProductType() {
		return productType;
	}

	public void setProductType(String productType) {
		this.productType = productType;
	}
	
	public Double getArea() {
		return area;
	}

	public void setArea(Double area) {
		this.area = area;
	}
	
	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}
	
	public Double getSum() {
		return sum;
	}

	public void setSum(Double sum) {
		this.sum = sum;
	}
	
}